from config.config import Base
from selenium.webdriver.common.by import By
import time


class Page(Base):
    ss1_loc = (By.XPATH, '//*[@id="suggest-align"]')

    def ss1(self):
        self.send_keys(self.ss1_loc, "我在做软件测试")

    ss2_loc = (By.ID, 'input')

    def ss2(self):
        self.send_keys(self.ss2_loc, "我在做软件测试")

    ss_btn_loc = (By.ID, 'search-button')

    def ss_btn(self):
        self.click(self.ss_btn_loc)

    dy1_loc = (By.XPATH, '/html/body/div[6]/div[1]/div[1]/ul/li[1]/h3/a')

    def dy1(self):
        return self.text(self.dy1_loc)

    pt_loc = (By.XPATH, '/html/body/div[6]/div[1]/div[1]')

    def pt(self):
        self.find_elements(self.pt_loc)

    xyy_loc = (By.XPATH, '//*[@id="page"]/a[1]')

    def xyy(self):
        self.click(self.xyy_loc)

    pt2_loc = (By.XPATH, '/html/body/div[6]/div[1]/div[1]')

    def pt2(self):
        self.find_elements(self.pt2_loc)

    def test_01(self):
        self.open_url('https://www.so.com/')
        self.ss2()
        self.ss_btn()
        time.sleep(2)
        # print(self.dy1())
        dy11 = self.dy1()
        print(dy11)
        assert '我在做软件测试' in dy11
        time.sleep(2)
        self.pt()
        self.xyy()
        self.pt()
